import requests
import config.path_cnf as config
import config.params_cnf as params_cnf


class UserRightsApi(object):
    token_url = config.EGO_URL + config.TOKEN_URL
    verify_token_url = config.EGO_URL + config.VERIFY_TOKEN_URL
    address_url = config.EGO_URL + config.ADDRESS_URL

    # 获取Token（静态方法）
    @classmethod
    def get_token(cls):
        return requests.post(cls.token_url, json=params_cnf.CODE_BODY)

    # Token验证
    @classmethod
    def verify_token(cls):
        return requests.post(cls.verify_token_url, json=params_cnf.TOKEN_BODY)

    # 获取地址信息
    @classmethod
    def get_address(cls):
        return requests.get(cls.address_url, headers=params_cnf.TOKEN_BODY)


if __name__ == '__main__':
    # 取Token
    token = UserRightsApi.get_token()
    print(token)

    # Token验证
    print(UserRightsApi.verify_token())

    # 获取地址信息
    print(UserRightsApi.get_address())
